package tt.dz.order.service.rpc.rpchander;

import org.apache.avro.generic.GenericRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import tt.dz.order.service.OrderService;
import tt.dz.order.vo.RetVO;

/**
 * 统付、企业支付时，修改订单状态
 * 
 * @author NIBO
 *
 */
@Component("unifyAndCorpPayHander")
public class UnifyAndCorpPayHander implements BaseHander {
	private static Logger log = LoggerFactory.getLogger(UnifyAndCorpPayHander.class);
	@Autowired
	OrderService orderService;

	@Override
	public RetVO dohander(GenericRecord req) {
		RetVO retVO = new RetVO(RetVO.SuccessCode, null, null);
		// 统付、企业支付时，修改订单状态
		try {
			String reqStr = req.get("orderIds").toString();
			log.info("统付、企业支付reqStr：" + reqStr);
			orderService.transChangeOrderStatusToDone(reqStr);
		} catch (Exception e) {
			log.error("统付、企业支付时，修改订单状态发生异常", e);
			retVO.setRetCode(RetVO.FailCode);
			retVO.setResultCode("1020300");
			retVO.setErrorMsg(e.getMessage());
		}
		return retVO;
	}

}
